﻿#pragma once

#include "pch.h"

class CMyListBox : public CVSListBox
{
	DECLARE_DYNAMIC(CMyListBox)

public:
	CMyListBox();
	virtual ~CMyListBox();
	virtual BOOL EditItem(int iIndex) { return TRUE; };
	virtual void OnAfterMoveItemDown(int iItem);
	virtual void OnAfterMoveItemUp(int iItem);

protected:
	DECLARE_MESSAGE_MAP()
};



// CPreImport 对话框

class CPreImportDlg : public CDialogEx
{
	DECLARE_DYNAMIC(CPreImportDlg)

public:
	CPreImportDlg(CWnd* pParent = nullptr);   // 标准构造函数
	virtual ~CPreImportDlg();

// 对话框数据
#ifdef AFX_DESIGN_TIME
	enum { IDD = IDD_PREIMPORT };
#endif

protected:
	virtual void OnOK();
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 支持
	virtual BOOL OnInitDialog();
	afx_msg void OnGetdispinfoViewlist(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnSelchangeCikuname();
	afx_msg void OnCbnSelchangeDelimiter();
	afx_msg void OnCbnEditUpdateDelimiter();
	afx_msg void OnKillfocusCikuname();
	afx_msg void OnSelchangeCodegen();
	afx_msg void OnKillfocusEditRules();
	afx_msg void OnBnClickedCheckCustompath();
	afx_msg void OnChangeEdit2();
	DECLARE_MESSAGE_MAP()
public:
	std::vector<CString> m_tbl;
	std::vector<CString> m_viewcode;
	std::vector<std::vector<CString>> m_viewdata;
	std::vector<std::vector<CString>> m_predata;
	std::vector<CString> colinfo;
	const char *buffer;
	size_t dwsize;
	CString lasttbl;
	CMyListBox m_List;
	CComboBox m_delimiter;
	char delimiter;
	int CRLF = 1;
	CString def = L"";
	CString selck;
	CString codegen = _T("无");
	CString rules = _T("code_e2=p11+p12+p21+p22\r\ncode_e3=p11+p21+p31+p32\r\ncode_a4=p11+p21+p31+n11");
	CString dictpath;
	CListCtrl m_ViewList;
	CComboBox m_cksel;
	BOOL firstishead;
	BOOL isduoyi;
	CEdit m_def;
	CButton m_isduoyi;
	CComboBox m_codegen;
	CEdit m_rules;
	CButton m_custompath;
	std::wstring prebuffer;
	Hanzi::CodeGenerater *pGen = nullptr;

public:
	void Predataview(char delimiter = '\0');
	void LoadDictFromRes(WORD ID);
	void FreshPreView();
	void CodeGenSwitch();
	void CodeGen();
};
